package com.wangsai.framework.supersecurity.satoken;

import com.wangsai.framework.supersecurity.client.UserStore;
import com.wangsai.framework.supersecurity.core.config.SuperSecurityConfig;
import com.wangsai.framework.supersecurity.core.context.chain.UserContextFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Mr.Wang
 * @date 2021-08-14 23:54
 */
@Configuration
public class SuperSecuritySaConfiguration {

    @Bean
    public SaWebMvcConfigurer saWebMvcConfigurer(@Autowired(required = false) SuperSecurityConfig superSecurityConfig) {
        return new SaWebMvcConfigurer(superSecurityConfig);
    }

    @Bean
    @ConditionalOnMissingBean
    public UserStore saUserStore() {
        return new DefaultSaUserStore();
    }

    @Bean
    public UserContextFilter saUserContextFilter(UserStore userStore) {
        return new SaUserContextFilter(userStore);
    }

}